PARTY ART
=========

Available bodies: four birds, four turtles, four lions, four gorillas,
four frogs and four octopuses (24 total). Every one of the 12 jobs has a hat.
The 20 non-bird bodies use identical casting poses except for mouth pixels;
casting and chanting share equipment anchors and the same hat frame.
Saved softshell_turtle appearances resolve to red_eared_slider.
The turtles use the same nine poses, equipment anchors and composed
15-frame battle layout as the birds. New members can roll any loaded body.

Party members are creatures. A member's sprite is built from layers, back to
front:

    weapon (when it's drawn behind) - bird - armor - hat - weapon

The bird is the member's own (rolled when they join, saved with the run),
the hat is their job's, the armor their chest piece's, and the weapon shows
only while they swing. The game combines a member's layers into one sheet
the first time it needs that look, then thickens the black outline round
the whole lot (see Outline). Change a file here to change the art; no
rebuild needed.

Files
-----
party_art.json        frame size, how big the birds draw, the pose list and
                      which pose each battle frame uses
Bodies/<bird>.png     one row of 64x64 frames, one per pose, in the order of
                      party_art.json's "poses"
Bodies/<bird>.json    per pose: its frame and the points the layers sit on:
                        head   front of the head, just above the eye (hats)
                        torso  top middle of the chest (armor)
                        hand   inside the fist (or wing tip) that holds a
                               weapon, set for windup and strike, the
                               swing poses; kept far enough in that
                               every weapon fits the weapon frame
                      Optional "hatCrown": [x0, y0, x1, y1] round the head
                      point, for a head bigger than the hats: head texels
                      in it that stick out into the open air round the hat,
                      above its brim, are hidden (the dumbo octopus's far
                      ear fin, the violet octopus's mantle), as is head
                      behind the hat down to its lowest row there; head
                      left in a gap the hat closes in turns outline black.
Hats/<job id>.png     a job's hat: ranger.png is the Ranger's. A job with no
                      hat file shows a bare bird.
Armor/<id>.png        a chest piece's armor: by item id (leather_armor.png),
                      else by one of its tags (cloth.png, hide.png, metal.png)
Weapons/<id>.png      a weapon: by item id (oathkeeper.png), else by its
                      subType (sword, dagger, wand, spear, bow, axe,
                      hammer, staff). Made by Tools/party_art from each
                      weapon's inventory icon (see its README): cell 0
                      raised in the windup, cell 1 held level in the
                      strike; a bow has one cell, upright, for the strike.

Every bird, hat, armor and weapon needs its .json beside it. A new bird in
Bodies is one new members can be rolled.

Hat, armor and weapon JSON
--------------------------
The PNG is a row of equal cells.

    {
      "anchor": "head",               the body point it sits on: head, torso or hand
      "cellWidth": 27,
      "cellHeight": 21,
      "poses": {
        "idle":   { "frame": 0, "seat": [2, 15] },
        "windup": { "frame": 2, "seat": [4, 19], "behind": true }
      }
    }

"seat" is the texel of that cell (x right, y down, from its top-left) that
lands on the body's point. "behind" draws it behind the bird (a sword raised
behind the head). A pose left out draws nothing of that layer in that pose:
a weapon only needs windup and strike.

Battle frames
-------------
"battleFrames" is the sheet the game builds, numbered as in
Data/battle_animations.json:

    0 idle     1 ready / defend   2 map step     3 move / step
    4-5 attack swing (mainhand weapon)           6-7 casting
    8 cast / victory   9 hit   10 kneel   11 dead
    12-13 offhand swing (Dual Wield's offhand weapon)
    14 idle breath (the idle clip loops 0 and 14)

Frame 14 ("breath": true) is the combined idle with everything above the
waist one texel lower and the feet planted, made by the game, not drawn
(PartyArt.Breathe): it drops the row between the chest (the torso point)
and the feet that's most like the row above it, so no detail is lost. The
idle clip holds each frame 1/1.5 s at any Battle Speed ("ignoreSpeed"), and
each party column starts at its own point in the loop.

Frame 1 is the "defend" pose (a guard; it's also the Skill-charging "ready"
pose) and frame 9 the "flinch" pose (a hit), both drawn on every body after
its nine AI poses. A frame marked "weapon": "main" or "off" draws that
hand's weapon; no other frame does. Those frames are "weaponMargin" (8)
texels wider on each side, so a weapon held level out in front isn't cut
off; every other frame stays frameWidth wide. A frame marked "hat": false draws no hat
(the dead and flinch frames: the hat doesn't follow a body thrown about). An overlay with no entry for flinch or defend uses its
cheer or idle entry (PartyArt.DrawOverlay). The defend frames (a front-on
guard, fists up) are in Tools/party_art/source/extra_poses.

Size
----
"pixelsPerUnit" sets how big the birds are. Enemies draw at 128; 192 makes a
bird about as tall as the old party sprites, so the formation doesn't
crowd. "groundRow" is the texel row under the finished sprite's lowest
texel (the outline under the feet) and "groundLocalY" keeps that where the
old sprites' feet were.

Outline
-------
"outline" is how thick the black outline round a finished sprite is, in
texels. The art has its own 1-texel outline; each texel more is a black
ring the game draws round the combined body, hat and gear (so where the hat
crosses the face its edge stays thin). It's 2. "outlineShape" decides which
clear texels the ring fills: "plus" only those beside, above or below the
sprite, so straight edges are 2 thick and diagonal steps stay lighter;
"square" also fills the diagonal corners (heavier, blockier). Changing
"outline" moves the outline under the feet down, so move "groundRow" with it
(the art stands on row groundRow - outline) and rebuild with the tool.

Races
-----
A member's race comes from their body: Data/races.json lists each race's
bodies, the core stats it starts with and the passives it always has.

Editing a race's sprites: the bodies are Bodies/<body>.png here, one strip
of 64x64 frames in the pose order of party_art.json (idle, walk, windup,
strike, crouch, cheer, dead, cast, chant, flinch, defend), feet on row 61,
shaded colours with a 1-texel black outline (the game adds the second ring).
Edit them in place and restart the game. Keep each pose's head where it
is, or move its "head" point in Bodies/<body>.json to match (that's where
hats sit). The art tool keeps a body you've edited by hand when it
rebuilds (see Tools/party_art/README.md).

Making a race, with no code:
1. Its bodies: Bodies/<body id>.png + .json as above. Copy a similar
   body's .json and move the points, or let Tools/party_art make both from
   an AI sheet.
2. An entry in Data/races.json:
     "newt": {
       "name": "Newt",
       "description": "Small, slick and hard to keep down.",
       "stats": { "lungs": 2, "arms": -1 },
       "favoredStat": "lungs",
       "passives": ["newt_regrowth"],
       "bodies": ["red_newt", "cave_newt"]
     }
   stats: core stat ids (feet, arms, brains, bones, heart, lungs), added
     to a new member's base stats once, when they join. Negatives work.
   favoredStat: optional. A recruit who joins with stat points to spare
     spends them at random; this stat is very slightly likelier to get
     each one (Settings/game_balance.json Leveling.raceFavoredStatWeight,
     1.25 = about 20% of points instead of 1 in 6). Autodidactic recruits
     ignore it. Leave it out for an even spread.
   passives: on for every member of the race, all the time, and listed
     under their Permanent Passives. Each is an ordinary passive:
     Data/Passives/<any folder>/<id>.json ({"displayName", "description"})
     plus <id>.lua with its hooks (Data/Passives/Personalities has small
     examples). Don't mark it "innate": that hands it to everyone.
   bodies: new members can now roll these; the body decides the race.
3. Lua sees it: member:getRace() / unit:getRace() give the race id, and
   hasPassive(id) is true for race passives.
Every body needs a race (a body in none gets no bonus). Changing a race's
stats only affects members made afterwards; changing its passives affects
everyone of that race, saved runs included. A typo in a stat, favoredStat or passive id
is skipped with a warning in Player.log.

Turning it off
--------------
"enabled": false goes back to the old job sheets in Sprites/Battle/Jobs.

Making the art
--------------
Tools/party_art/build_party_art.py builds Bodies and Hats from the AI
source sheets, all in one style: one texel per art pixel at the same size
for every body and hat, a few colours each shaded with a shadow, deep
shadow and highlight (lit from the top front), a black outline exactly one
texel thick. It pins every pose to the idle head so frames don't wobble,
uses one drawing per hat in every pose so hats don't jitter, finds each
pose's head and torso points, and writes a preview. Hand-drawn art dropped
in here should match that style. See Tools/party_art/README.md.
